<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 8.  有一组文本框，要求让每一个文本框在自己输入的时候，背景显示灰色，其他文本框显示白色。 -->
    <form action="" id="form">
        <input type="text"><br>
        <input type="text"><br>
        <input type="text"><br>
        <input type="text"><br>
        <input type="text"><br>
        <input type="text"><br>    
    </form>
    <script>
        var form = document.getElementById("form");
        var inputs = form.getElementsByTagName("input");
        for (var i = 0; i < inputs.length; i++) {
            inputs[i].onfocus = function () {
                for (var i = 0; i < inputs.length; i++) {
                    inputs[i].style.backgroundColor = "#fff";
                }
                this.style.backgroundColor = "#999";
            }
            inputs[i].onblur = function () {
                this.style.backgroundColor = "#fff";
            }
        }
    </script>
</body>
</html>